﻿Imports System
Imports Microsoft.VisualBasic
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Linq
Imports System.Linq.Expressions
Imports System.Reflection
Imports System.IO
Imports System.Diagnostics.Process
Imports Microsoft.Win32
Imports System.Threading

Imports DanhMuc
Imports BaoCao
Imports HeThong
Imports NhapLieu
Imports Publics
Imports DevExpress.XtraBars
Imports DevExpress.Skins

Public Class FrmMain
    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        '// Khởi tạo chuỗi kết nối csdl
        SetConnectTion()
        '// Kết nối CSDL
        ConnectToDB()
        '// Khởi tạo các object
        InitClient()
    End Sub
    Private Sub InitClient(Optional ByVal Name As String = "")
        Dim thread As New Thread(AddressOf GetAllTaiLieu)
        thread.IsBackground = True
        thread.Start()
        Dim threadKH As New Thread(AddressOf GetAllKhachHang)
        threadKH.IsBackground = True
        threadKH.Start()

        Load_DMPhimTat()
        Load_ThoiGianLamViec()

        If String.IsNullOrEmpty(Name) Then
            Dim frmLogin As New FrmDangNhap
            frmLogin.ShowDialog()
            Dim FlagExit = frmLogin.IsThoat
            If FlagExit Then
                If Not String.IsNullOrEmpty("Mta.Cafe") Then
                    Dim process As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("Mta.Cafe")
                    For Each p As System.Diagnostics.Process In process
                        p.Kill()
                    Next
                End If
                Exit Sub
            End If
        Else
            vUser = New clsNguoiDung
            Dim objNSD = (From ds In dbTV.DM_NhanViens Where ds.UserName.ToLower = "superadmin" Or ds.UserName.ToLower = "admin" Select ds).FirstOrDefault
            If objNSD IsNot Nothing Then
                vUser.CanBo = objNSD
                vUser.DonVi = (From ds In dbTV.DM_DonVis Where ds.InUsed AndAlso ds.ID = objNSD.ID_DonVi Select ds).FirstOrDefault
                'btnNguoiDung.Visibility = BarItemVisibility.Never
                'btnHoTen.Visibility = BarItemVisibility.Never
                'vUser.Quyen = lstQuyen
            End If
        End If
        If vUser Is Nothing Then
            Application.Exit()
            Return
        End If
        If Not String.IsNullOrEmpty(Name) Then
            PhanQuyenMain()
        End If
        barStaticNguoiSuDung.Caption = String.Format("Người sử dụng: {0}", vUser.CanBo.HoTen)
    End Sub
    'Private Sub PhanQuyen()
    '    If Not New List(Of String)(New String() {"admin", "superadmin"}).Contains(vUser.CanBo.UserName.ToLower) Then
    '        Me.MenuItemHoaDonBanLe.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
    '        Me.NBItemHoaDonBanLe.Visible = False
    '        Me.MenuItemQuanLiPhongBan.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
    '        Me.NBItemQuanLiPhongBan.Visible = False
    '        Me.MenuItemQuanLiTaiKhoanDangNhap.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
    '        Me.NBItemQuanLiTaiKhoanDangNhap.Visible = False
    '        Me.MenuItemTapHopGiaThanh.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
    '        Me.NBItemTapHopGiaThanh.Visible = False
    '        Me.MenuItemTieuHaoNguyenLieu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
    '        Me.NBItemTinhTieuHaoNguyenLieu.Visible = False
    '        Me.MenuItemXuatTieuHaoNguyenLieu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
    '        Me.NBItemXuatTieuHaoNguyenLieu.Visible = False
    '        Me.MenuItemPhieuChiTienMat.Visibility = BarItemVisibility.Never
    '        Me.MenuItemPhieuThuTienMat.Visibility = BarItemVisibility.Never
    '        Me.MenuItemBaoCaoTongHopCongNo.Visibility = BarItemVisibility.Never
    '        Me.NBItemNhapSoDuDauKyNguyenLieu.Visible = False
    '        Me.MenuItemNhapSoDuDauKyNguyenLieu.Visibility = BarItemVisibility.Never

    '        'Me.MenuItemBaoCaoXuatKho.Visibility = BarItemVisibility.Never
    '    Else

    '    End If

    'End Sub

    Private bolHoiThoat As Boolean

    Private Sub FrmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        'If Not bolHoiThoat Then
        '    If MsgAskDelete("Bạn có muốn thoát chương trình không?") = vMsg.vReSult.Yes Then
        '        Me.Close()
        '        bolHoiThoat = True
        '    Else
        '        Return
        '    End If
        'End If

    End Sub
    Private Sub FrmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        barStaticThoiGianLamViec.Caption = String.Format("Bạn đang làm việc tháng {0} năm {1}", vIntKTThang, vIntKTNam)
        Dim threadKH As Thread
        threadKH = New Thread(AddressOf GetAllDMKhachHang)
        threadKH.IsBackground = True
        threadKH.Start()

        Dim threadSP As Thread
        threadSP = New Thread(AddressOf GetAllDMSanPham)
        threadSP.IsBackground = True
        threadSP.Start()

        InitSkins()
        SetDefaulSkin()

    End Sub

    Private Sub InitSkins()
        DevExpress.UserSkins.BonusSkins.Register()
        DevExpress.UserSkins.OfficeSkins.Register()
        DevExpress.Skins.SkinManager.EnableFormSkins()
        Application.EnableVisualStyles()
        BarManagerMain.ForceInitialize()
        For Each iSkin As SkinContainer In SkinManager.Default.Skins
            Dim item As BarButtonItem = New BarButtonItem(BarManagerMain, iSkin.SkinName)
            item.ImageIndex = 19
            iPaintStyle.AddItem(item)
            AddHandler item.ItemClick, AddressOf SkinClick
        Next
    End Sub
    Private Sub SkinClick(ByVal s As Object, ByVal e As ItemClickEventArgs)
        Dim skinName As String = e.Item.Caption
        DevExpress.LookAndFeel.UserLookAndFeel.[Default].SetSkinStyle(skinName)
        BarManagerMain.GetController().PaintStyleName = skinName
        iPaintStyle.Hint = e.Item.Caption
        'iPaintStyle.Caption = iPaintStyle.Hint;
        iPaintStyle.Hint = iPaintStyle.Caption

        ' Ghi skin vào bảng cấu hình
        Dim doc As XElement = XElement.Load("config.xml")
        Dim objSkin = (From ds In doc.Descendants("config") Where CStr(ds.Element("configname")) = "skindefaultname" Select ds).FirstOrDefault

        If objSkin Is Nothing Then
            Dim ID As Integer = (From ds In doc.Descendants("config") Select CInt(ds.Attribute("ID"))).Max
            Dim strID = CStr(ID + 1)

            Dim objAdd As New XElement("config", New XAttribute("ID", strID), New XElement("configname", "skindefaultname"), New XElement("configvalue", "Office 2007 Blue"))
            doc.Add(objAdd)
            doc.Save("config.xml")
        Else
            '//Ghi skin vao config
            Dim objUpdate = (From ds In doc.Descendants("config") Where CStr(ds.Element("configname")) = "skindefaultname" Select ds).FirstOrDefault
            objUpdate.SetElementValue("configvalue", skinName)
            doc.Save("config.xml")
        End If


    End Sub
    Private Sub SetDefaulSkin()
        Dim doc As XDocument = XDocument.Load("config.xml")
        Dim skinName As String = (From ds In doc.Descendants("config") Where CStr(ds.Element("configname")) = "skindefaultname" Select CStr(ds.Element("configvalue"))).FirstOrDefault
        DevExpress.LookAndFeel.UserLookAndFeel.[Default].SetSkinStyle(skinName)
        BarManagerMain.GetController().PaintStyleName = skinName
        iPaintStyle.Hint = skinName
        iPaintStyle.Hint = iPaintStyle.Caption
    End Sub
    Private Sub GetAllDMSanPham()
        'lstSourceAllSanPham = GetAll_DMSanPham()
    End Sub
    Private Sub GetAllDMKhachHang()
        lstSourceAllKhachHang = GetAll_DMKhachHang()
    End Sub
    Private Sub SetConnectTion()
        Dim doc As XDocument = XDocument.Load("config.xml")
        Dim strMayChu As String = (From ds In doc.Descendants("config") Where CStr(ds.Element("configname")) = "maychu" Select CStr(ds.Element("configvalue"))).FirstOrDefault
        Dim strCsdl As String = (From ds In doc.Descendants("config") Where CStr(ds.Element("configname")) = "csdl" Select CStr(ds.Element("configvalue"))).FirstOrDefault
        Dim strUser As String = (From ds In doc.Descendants("config") Where CStr(ds.Element("configname")) = "username" Select CStr(ds.Element("configvalue"))).FirstOrDefault
        Dim strPass As String = (From ds In doc.Descendants("config") Where CStr(ds.Element("configname")) = "password" Select CStr(ds.Element("configvalue"))).FirstOrDefault

        'ConnectionString = String.Format("Server={0};Database={1};UID={2};PWD={3};Persist Security Info=True", "DUONGTHIENIT-PC\SQLEXPRESS", "NhaHang", "sa", "1")
        ConnectionString = String.Format("Server={0};Database={1};UID={2};PWD={3};Persist Security Info=True", strMayChu, strCsdl, strUser, strPass)
    End Sub

    Private Sub GetAllTaiLieu()
        'lstSourceAllTaiLieu = GetAll_DMTaiLieu()
    End Sub

    Private Sub GetAllKhachHang()
        lstSourceAllKhachHang = GetAll_DMKhachHang()
    End Sub

    Public Shared Sub ShowForm(ByVal Frm As Form)
        Try
            Dim ChildForm As New Form
            For Each ChildForm In FrmMain.MdiChildren()
                If ChildForm.Name = Frm.Name Then
                    'ChildForm.Activate()
                    'ChildForm.Focus()
                    ChildForm.Close()
                    Exit For
                End If
            Next
            Frm.MdiParent = FrmMain
            Frm.WindowState = FormWindowState.Maximized
            Frm.Show()
            Frm.Activate()
        Catch ex As Exception
            MsgBox(ex.ToString())
        End Try
    End Sub
#Region "Menu Danh mục"



#End Region


    Private Sub MenuItemThoat_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemThoat.ItemClick
        Me.Close()
    End Sub


    Private Sub MenuItemDanhMucKho_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemDanhMucKho.ItemClick
        Dim frm As New FrmDMKho
        ShowForm(frm)
    End Sub

    Private Sub NBItemCaiDatPhimtat_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemCaiDatPhimtat.LinkClicked
        Dim frm As New FrmPhimTat
        ShowForm(frm)
    End Sub

    Private Sub MenuItemCaiDatPhimTat_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemCaiDatPhimTat.ItemClick
        NBItemCaiDatPhimtat_LinkClicked(Nothing, Nothing)
    End Sub

    Private Sub NBItemDM_Kho_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemDM_Kho.LinkClicked
        Dim frm As New FrmDMKho
        ShowForm(frm)
    End Sub

    Private Sub NBItemDM_KhachHang_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemDM_KhachHang.LinkClicked
        Dim frm As New FrmDMKhachHang
        ShowForm(frm)
    End Sub

    Private Sub MenuItemDanhMucKhachHang_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemDanhMucKhachHang.ItemClick
        NBItemDM_KhachHang_LinkClicked(Nothing, Nothing)
    End Sub



    Private Sub NBItemDM_TCNX_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemDM_TCNX.LinkClicked
        Dim frm As New FrmDMTCNX
        ShowForm(frm)
    End Sub

    Private Sub MenuItemDanhMucTCNX_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemDanhMucTCNX.ItemClick
        NBItemDM_TCNX_LinkClicked(Nothing, Nothing)
    End Sub

    Private Sub barStaticThoiGianLamViec_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barStaticThoiGianLamViec.ItemClick
        Dim frm As New FrmThangNam
        frm.StartPosition = FormStartPosition.CenterParent
        frm.ShowDialog()
        vIntKTNam = frm.nam
        vIntKTThang = frm.thang
        barStaticThoiGianLamViec.Caption = String.Format("Bạn đang làm việc tháng {0} năm {1}", vIntKTThang, vIntKTNam)
    End Sub

    Private Sub MenuItemQuanLiTaiKhoanDangNhap_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemQuanLiTaiKhoanDangNhap.ItemClick
        Dim frm As New FrmTaiKhoan_NguoiSuDung
        ShowForm(frm)
    End Sub

    Private Sub MenuItemQuanLiPhongBan_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemQuanLiPhongBan.ItemClick
        Dim frm As New FrmDonVi
        ShowForm(frm)
    End Sub

    

    Private Sub MenuItemDoiMatKhau_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemDoiMatKhau.ItemClick
        Dim frm As New FrmDoiMatKhau
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.ShowDialog()

    End Sub

    Private Sub MenuItemDanhMucThanhVien_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemDanhMucThanhVien.ItemClick
        NBItemDM_ThanhVien_LinkClicked(Nothing, Nothing)
    End Sub

    Private Sub NBItemDM_ThanhVien_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemDM_ThanhVien.LinkClicked
        Dim frm As New FrmDMThanhVien
        ShowForm(frm)
    End Sub

   

    Private Sub MenuItemDanhMucNhomVatTu_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemDanhMucNhomVatTu.ItemClick
        Dim frm As New FrmDMNhomVatTu
        ShowForm(frm)
    End Sub

    Private Sub MenuItemDanhMucVatTu_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemDanhMucVatTu.ItemClick
        Dim frm As New FrmDMVatTu
        ShowForm(frm)
    End Sub

    Private Sub MenuItemPhieuNhapVatTu_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemPhieuNhapVatTu.ItemClick
        NBItemPhieuNhapVatTu_LinkClicked(Nothing, Nothing)
    End Sub

    Private Sub NBItemPhieuNhapVatTu_LinkClicked(ByVal sender As Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemPhieuNhapVatTu.LinkClicked
        Dim frmThoiGian As New FrmThangNam
        frmThoiGian.ShowDialog()
        If frmThoiGian.thang = 0 Then
            Exit Sub
        End If
        Dim frm As New FrmVatTu
        frm.Thang = frmThoiGian.thang
        frm.Nam = frmThoiGian.nam
        frm.LaNhap = True
        ShowForm(frm)
    End Sub

    Private Sub MenuItemBaoCaoNXTVatTu_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemBaoCaoNXTVatTu.ItemClick
        Dim frm As New FrmThangNamBaoCao
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.ShowDialog()
        If frm.TuNgay Is Nothing Then
            Exit Sub
        End If
        Dim frmLoc As New FrmDieuKienLoc_BaoCaoNXTVatTu

        frmLoc.TuNgay = frm.TuNgay
        frmLoc.DenNgay = frm.DenNgay
        frmLoc.StartPosition = FormStartPosition.CenterScreen
        frmLoc.ShowDialog()
    End Sub

    

    Private Sub NBItemNhapSoDuDauKyNguyenLieu_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemNhapSoDuDauKyNguyenLieu.LinkClicked
        Dim frmChonNam As New FrmNam
        frmChonNam.ShowDialog()
        If frmChonNam.Nam = 0 OrElse frmChonNam.Nam Is Nothing Then
            Return
        End If
        Dim FrmKho As New DanhMuc.FrmDMKho
        FrmKho.StartPosition = FormStartPosition.CenterScreen
        FrmKho.LaChon = True
        FrmKho.ShowDialog()
        If FrmKho.IDKho IsNot Nothing AndAlso FrmKho.IDKho.Trim <> "" Then
            'Dim obj = (From ds In dbTV.DM_Khos Where ds.InUsed AndAlso ds.ID = FrmKho.IDKho Select ds).FirstOrDefault
            'Dim frm As New HeThong.FrmSoDuDK_SanPham
            'frm.objKho = obj
            'frm.Nam = frmChonNam.Nam
            'ShowForm(frm)
        End If
    End Sub

    Private Sub MenuItemNhapSoDuDauKyNguyenLieu_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemNhapSoDuDauKyNguyenLieu.ItemClick
        NBItemNhapSoDuDauKyNguyenLieu_LinkClicked(Nothing, Nothing)
    End Sub

    Private Sub MenuItemPhieuThuTienMat_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemPhieuThuTienMat.ItemClick
        Dim frmt As New FrmThangNam
        frmt.ShowDialog()
        If frmt.thang = 0 Or frmt.nam = 0 Then Return

        Dim frm As New FrmPhieuThuST
        frm.LoaiPhieu = ELoaiChungTu.PhieuThu
        frm.Thang = frmt.thang
        frm.Nam = frmt.nam
        ShowForm(frm)
    End Sub

    Private Sub MenuItemPhieuChiTienMat_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemPhieuChiTienMat.ItemClick
        Dim frmt As New FrmThangNam
        frmt.ShowDialog()
        If frmt.thang = 0 Or frmt.nam = 0 Then Return

        Dim frm As New FrmPhieuThuST
        frm.LoaiPhieu = ELoaiChungTu.PhieuChi
        frm.Thang = frmt.thang
        frm.Nam = frmt.nam
        ShowForm(frm)
    End Sub

    Private Sub MenuItemBaoCaoTongHopCongNo_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemBaoCaoTongHopCongNo.ItemClick
        Dim frm As New FrmBaoCaoCongNoSieuThi
        ShowForm(frm)
    End Sub


    Private Sub NBItemQuanLiQuyen_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemQuanLiQuyen.LinkClicked
        Dim frm As New FrmDMQuyen
        ShowForm(frm)
    End Sub

    Private Sub MenuItemQuanLiQuyen_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemQuanLiQuyen.ItemClick
        NBItemQuanLiQuyen_LinkClicked(Nothing, Nothing)
    End Sub

    Private Sub NBItemQuanLiPhongBan_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemQuanLiPhongBan.LinkClicked
        MenuItemQuanLiPhongBan_ItemClick(Nothing, Nothing)
    End Sub

    Private Sub NBItemQuanLiTaiKhoanDangNhap_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemQuanLiTaiKhoanDangNhap.LinkClicked
        MenuItemQuanLiTaiKhoanDangNhap_ItemClick(Nothing, Nothing)
    End Sub

    Private Sub NBItemThoat_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemThoat.LinkClicked
        MenuItemThoat_ItemClick(Nothing, Nothing)
    End Sub

    Private Sub NBItemDoiMatKhau_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemDoiMatKhau.LinkClicked
        MenuItemDoiMatKhau_ItemClick(Nothing, Nothing)
    End Sub

    Private Sub FrmMain_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        If vUser Is Nothing Then
            Application.ExitThread()
        Else
            PhanQuyenMain()
        End If
    End Sub

    Private Sub NBItemPhieuThuTienMat_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemPhieuThuTienMat.LinkClicked
        MenuItemPhieuThuTienMat_ItemClick(Nothing, Nothing)
    End Sub

    Private Sub NBItemDM_NhomVatTu_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemDM_NhomVatTu.LinkClicked
        MenuItemDanhMucNhomVatTu_ItemClick(Nothing, Nothing)
    End Sub

    Private Sub NBItemDM_VatTu_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemDM_VatTu.LinkClicked
        MenuItemDanhMucVatTu_ItemClick(Nothing, Nothing)
    End Sub

    Private Sub NBItemBC_NXTVatTu_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemBC_NXTVatTu.LinkClicked
        MenuItemBaoCaoNXTVatTu_ItemClick(Nothing, Nothing)
    End Sub

    


    Private Sub NBItemDangNhapTaiKhoanKhac_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemDangNhapTaiKhoanKhac.LinkClicked
        Dim frm As New FrmDangNhap
        frm.StartPosition = FormStartPosition.CenterScreen
        frm.ShowDialog()
        PhanQuyenMain()
    End Sub

    Private Sub MenuItemDangNhapVoiTaiKhoanKhac_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemDangNhapVoiTaiKhoanKhac.ItemClick
        NBItemDangNhapTaiKhoanKhac_LinkClicked(Nothing, Nothing)
    End Sub

    Private Sub NBItemCauHinhKetNoiDuLieu_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemCauHinhKetNoiDuLieu.LinkClicked
        
    End Sub

    Private Sub MenuItemCauHinhKetNoiDuLieu_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuItemCauHinhKetNoiDuLieu.ItemClick
        NBItemCauHinhKetNoiDuLieu_LinkClicked(Nothing, Nothing)
    End Sub

    Private Sub MenuitemNhatKyHeThong_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles MenuitemNhatKyHeThong.ItemClick
        NBItemNhatKyHeThong_LinkClicked(Nothing, Nothing)
    End Sub

    Private Sub NBItemNhatKyHeThong_LinkClicked(ByVal sender As System.Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles NBItemNhatKyHeThong.LinkClicked
        Dim frmThoiGian As New Publics.FrmThangNamBaoCao
        frmThoiGian.StartPosition = FormStartPosition.CenterScreen
        frmThoiGian.ShowDialog()
        If frmThoiGian.TuNgay IsNot Nothing Then
            Dim frm As New frmNhatKy
            frm.TuNgay = frmThoiGian.TuNgay
            frm.DenNgay = frmThoiGian.DenNgay
            ShowForm(frm)
        End If
        
    End Sub
End Class
